#include "railroad_car.hpp"
#include "iostream"
RailroadWagon::RailroadWagon(RailroadCarProperty *property)
    : id(0), property(property), load(0.0) {}

RailroadWagon::~RailroadWagon() {
    // Assuming the property should not be deleted here if it's shared among
    // multiple wagons If it's not shared, you should delete the property here
    // delete property;
}
/**
 * @brief Get the Friction object
 * 计算摩擦力
 * @param v 速度，km/h
 * @param w_i 附加阻力系数，如坡道、曲线等
 * @return fp_type 阻力，kN
 */
fp_type RailroadWagon::friction(fp_type v, fp_type w_i) {

    // 计算摩擦力
    fp_type friction = (1.07 + 0.0011 * v + 0.000236 * v * v + w_i) *
                      9.81 * // 基本阻力乘上g之后的单位为N/t
                      ((this->property->deadWeight + this->load)) / 1000;
    return friction;
}
